Skip to content

PROTM-2270: Add job management API (list/get/cancel) - #181

Open
sandshoes wants to merge 1 commit into
mainfrom
tommy/protm-2270-ts-sdk-job-management-api
Open

sandshoes wants to merge 1 commit into
mainfrom
tommy/protm-2270-ts-sdk-job-management-api

Conversation

@sandshoes

Copy link
Copy Markdown
Contributor

Summary

Adds a jobs namespace to TinybirdClient (and standalone functions in src/api/jobs.ts) wrapping Tinybird's /v0/jobs endpoints, so the SDK can inspect and manage the async jobs it triggers (ingest/append/replace, connector syncs) instead of only firing them — bringing parity with tb job ls/details/cancel.

Linear: https://linear.app/tinybird/issue/PROTM-2270/typescript-sdk-add-job-management-api-listgetcancelretry

  • client.jobs.list({ status?, kind? }) → GET /v0/jobs
  • client.jobs.get(jobId) → GET /v0/jobs/{job_id}
  • client.jobs.cancel(jobId) → POST /v0/jobs/{job_id}/cancel

New files: src/api/jobs.ts (raw API layer, following the src/api/branches.ts pattern — a JobApiConfig + JobApiError + standalone functions using the shared fetcher) and src/client/jobs.ts (JobsNamespace, mirroring TokensNamespace exactly), wired into TinybirdClient in src/client/base.ts, with types/functions exported from src/index.ts.

retry was scoped out

The ticket description mentions tb job ... retry, but I could not confirm a real /v0/jobs/{job_id}/retry backend endpoint exists:

  • The installed Forward CLI client (tinybird/tb/client.py in the Python SDK's venv) only implements jobs(), job(), and job_cancel() — no retry method.
  • The CLI's tb job command group (tinybird/tb/modules/job.py) only defines ls, details, and cancel subcommands — there is no tb job retry command at all.
  • Grepping platform-api for job retry routes/handlers (/retry, retry_job, job_id.*retry) turned up nothing beyond unrelated HTTP-client retry logic.
  • The sibling Python SDK ticket (PROTM-2264, same scope) has no related commits/branches in tinybird-sdk-python's git history to cross-check against.

Given this, I implemented list/get/cancel only rather than ship a retry() call against an endpoint that may not exist. If a retry endpoint does exist, it should be added as a follow-up once confirmed.

Test plan

  • pnpm typecheck passes
  • pnpm test:run passes (1082 tests, including new src/api/jobs.test.ts and src/client/jobs.test.ts)
  • New tests cover: listing with/without status/kind filters, get by id (incl. URL-encoding), cancel, custom fetch override, 404 handling, and generic error-body propagation
  • CHANGELOG.md and package.json version intentionally left untouched per repo convention

🤖 Generated with Claude Code

Adds a `jobs` namespace to `TinybirdClient` (and standalone API
functions in `src/api/jobs.ts`) wrapping `/v0/jobs`, so the SDK can
inspect and manage the async jobs it triggers (ingest/append/replace,
connector syncs) instead of only firing them.

- `client.jobs.list({ status?, kind? })` -> GET /v0/jobs
- `client.jobs.get(jobId)` -> GET /v0/jobs/{job_id}
- `client.jobs.cancel(jobId)` -> POST /v0/jobs/{job_id}/cancel

`retry` was intentionally left out: there is no confirmed
`/v0/jobs/{job_id}/retry` endpoint. The installed Forward CLI client
(tinybird/tb/client.py) only implements `jobs()`, `job()` and
`job_cancel()`, and the CLI's `tb job` command group has no `retry`
subcommand (only `ls`, `details`, `cancel`). A grep of platform-api
found no `/v0/jobs/.../retry` route, and the sibling Python SDK ticket
(PROTM-2264) has no related work in its git history. Shipping a
`retry()` that calls a nonexistent endpoint would be worse than
leaving it out, so it's scoped out pending backend confirmation.

Refs PROTM-2270

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants